<template>
	<view>
		<u-swiper :list="lun" :height="250" :effect3d="true" :interval="3000" @click="click(idd)">
		</u-swiper>
		<uni-search-bar @confirm="shou" placeholder="搜索垃圾分类"></uni-search-bar>
		<uni-group title="热门搜索词">
			<view class="u-flex" style="flex-wrap: wrap;">
				<view style="width: 50%;" v-for="(item,index) in fen">{{item.keyword}}</view>
			</view>
		</uni-group>
	</view>
</template>

<script>
	import api from 'commer/apiURL.js'
	export default {
		data() {
			return {
				base:api.baseurl,
				lun:[],
				fen:[]
			}
		},
		onLoad() {
			this.getlun()
			this.getlun2()
		},
		methods: {
			getlun() {
				this.$get(this.base + '/prod-api/api/garbage-classification/ad-banner/list').then((res) => {
					res.data.forEach((item) => {
						this.lun.push({
							image: this.base + item.imgUrl,
							id: item.targetId
						})
					})
				})
			},
			getlun2(){
				this.$get(this.base+'/prod-api/api/garbage-classification/garbage-classification/hot/list').then((res)=>{
					this.fen = res.data.slice(0,10)
				})
			},
			shou(e){
				this.$get(this.base+'/prod-api/api/garbage-classification/garbage-classification/list',{
					name:e.value
				}).then((res)=>{
					let list = res.rows
					if(list.length == 0){
						uni.showToast({
							title:'没有该分类',
							icon:'none'
						})
					}else{
						uni.setStorage({
							key:'laji',
							data:list,
							success: (res) => {
								uni.navigateTo({
									url:'xianqqq'
								})
							}
						})
					}
					
				})
			},
		}
	}
</script>

<style>

</style>
